MOBILE-52: Fix snackbar cross and cross margins#721
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes several in-app UI and image-loading edge cases affecting snackbars and multi-display/foldable devices by correcting layout params usage, deferring constraint/margin calculations until layout, and stabilizing Glide sizing inputs to avoid cache misses.
Changes:
- Fix
ClassCastExceptionrisk in snackbar image by switching toConstraintLayout.LayoutParams. - Fix close (“cross”) button positioning by calculating margins after layout (
doOnLayout) and simplifying constraint updates via a new helper. - Fix Glide cache-key mismatch by reading screen metrics from
applicationContextconsistently; update unit test mocks accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/src/test/java/cloud/mindbox/mobile_sdk/inapp/data/managers/InAppGlideImageLoaderImplTest.kt | Mocks applicationContext to align with updated screen-metrics lookup. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/presentation/view/InAppImageView.kt | Uses ConstraintLayout.LayoutParams for snackbar image view to match its parent layout type. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/presentation/view/InAppCrossView.kt | Defers margin/constraint calculation until layout to avoid zero-sized parent measurements. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/presentation/view/InAppConstraintLayout.kt | Adds updateConstraints {} helper to reduce ConstraintSet boilerplate at call sites. |
| sdk/src/main/java/cloud/mindbox/mobile_sdk/Extensions.kt | Makes maxScreenDimension() use applicationContext display metrics for consistent Glide overrides/caching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sergeysozinov
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://tracker.yandex.ru/MOBILE-52
InAppImageView.kt — fix ClassCastException in snackbar: used FrameLayout.LayoutParams on a ConstraintLayout child; switched to ConstraintLayout.LayoutParams.
InAppCrossView.kt — fix close button stuck in corner: margins were computed from currentDialog.height/width which are 0 before layout. Wrapped margin calc + constraints in doOnLayout {} (works for both sync cache-hit and async paths).
Extensions.kt — fix Glide cache-key mismatch on foldables/multi-display: maxScreenDimension() returned different metrics for Application vs Activity context → different .override() → cache miss. Now always reads from applicationContext.